package com.sinping.qh.query.message;


import com.sinping.qh.query.base.Operator;
import com.sinping.qh.query.base.QueryParams;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Data
public class MessageInfoQuery implements QueryParams,Serializable {

    private static Map<String,String> aliasMap = new HashMap<>();
    private static Map<String,Operator> operateMap = new HashMap<>();

    private String title;
    private Date startGmtCreated;
    private Date endGmtCreated;
    private String status;
    private String type;

    private List<String> receiveIds;

    static {
//        aliasMap.put("title","title");
        aliasMap.put("startGmtCreated","gmt_created");
        aliasMap.put("endGmtCreated","gmt_created");
//        aliasMap.put("status", "status");
        aliasMap.put("receiveIds","receive_ids");

        operateMap.put("title",Operator.regex);
        operateMap.put("startGmtCreated",Operator.gte);
        operateMap.put("endGmtCreated", Operator.lte);
        operateMap.put("status", Operator.eq);
        operateMap.put("type", Operator.eq);

        operateMap.put("receiveIds", Operator.in); //包含
    }

    @Override
    public String getAlias(String fieldName) {
        return aliasMap.getOrDefault(fieldName, fieldName);
    }

    @Override
    public Operator getOperators(String fieldName) {
        return operateMap.getOrDefault(fieldName, Operator.eq);
    }
}
